package com.hqyj.controller;

import com.hqyj.pojo.User;
import com.hqyj.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

@RequestMapping("/user")
@Controller
public class UserController {

    //创建service对象
    @Autowired
    private UserService service;

    @RequestMapping("/indexPage")
    public String indexPage(String userName, Model model) {

        model.addAttribute("userName",userName);
        return "index1";
    }

    //访问index1界面
    @RequestMapping("/admin-list")
    public String adminList() {
        return "admin/admin-list";
    }

    @RequestMapping("/showUsersAjax")
    @ResponseBody
    public HashMap<String,Object> showUsers(User user, Model model, HttpServletRequest request) {
        return service.selectListAll(user, request);
    }

    @RequestMapping("/admin-add")
    public String adminDdd() {
        return "admin/admin-add";
    }

}
